package rentcar.service.impl;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import rentcar.domain.Car;
import rentcar.repository.CarDao;
import rentcar.service.CarService;

@Service
@Transactional
public class CarServiceImpl implements CarService {

	@Autowired
	private CarDao carRepository;

	@Override
	public void saveCar(Car car) {
		carRepository.save(car);
	}
	
	@Override
	public void deleteCar(Car car) {
		carRepository.delete(car);
	}
	
	@Override
	public void updateCar(Car car) {
		carRepository.update(car);
	}

	@Override
	public Car getCarByID(Long carId) {
		
		return carRepository.findById(carId);
	}
	
	@Override
	public List<Car> getCars() {
		
		List<Car> cars = carRepository.findAll();		
		return cars;
	}	
	
	
}
